/**
 * Lenovo Group
 * Copyright (c) 1999-2016 All Rights Reserved.
 */
package com.lenovo.lmrp.api.itsmgateway;

import java.util.List;

import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Response;

import com.lenovo.lmrp.api.model.RestResponse;
import com.lenovo.lmrp.api.model.view.EngineerVO;
import com.lenovo.lmrp.api.model.view.LoginData;

/**
 * 
 * @author wujin
 * @version v1.0
 */
@Consumes("application/json;charset-utf-8")
@Produces("application/json;charset-utf-8")
public interface IItsmEngineer {
    
    /**
     * authenticate engineer in ITSM system
     * 
     * @param itsmcode
     * @param loginData
     * @return
     */
    @POST
    @Path("/{itsmcode}/authenticate")
    public RestResponse<Integer> authenticate(@PathParam("itsmcode") String itsmcode, LoginData loginData);
    
    /**
     * change engineer properties, for example, email, phone, password
     * Only update no empty property
     * 
     * @param itsmcode      distinct ITSM system
     * @param engineerid
     * @param engineerVO        changed fields map, key is engineer property name
     * @return
     */
    @PUT
    @Path("/{itsmcode}/engineers/{engineerid}")
    public RestResponse<Integer> updateEngineer(@PathParam("itsmcode") String itsmcode,
                                                 @PathParam("engineerid") String engineerid,
                                                 EngineerVO engineerVO);
    
    /**
     * Submit reset password requistion
     * 
     * @param itsmcode      distinct ITSM system
     * @param loginName     user login name
     * @return
     */
    @POST
    @Path("/{itsmcode}/engineers/password")
    public RestResponse<Integer> resetPassword(@PathParam("itsmcode") String itsmcode,
                                               String loginName);
    
    /**
     * Obtain engineer information. Invoker should call Response.close() method to release resource!!!
     * 
     * @param itsmCode
     * @param engineerID
     * @return Response included entity is RestResponse<EngineerVO>
     */
    @GET
    @Path("/{itsmcode}/engineers/{engineerid}")
    public Response getEngineer(@PathParam("itsmcode") String itsmCode, @PathParam("engineerid") String engineerID);
    
    /**
     * List special ITSM engineer filter by condtion
     * query parameter is : filter={filter}&page={page}&limit={limit}&sorts={sort}
     * 
     * condition format is "key":value,"key":value...
     * 
     * supported filter: name, status, phone
     * 
     * @param itsmCode
     * @param condition
     * @param page
     * @param limit
     * @param sorts 
     * @return
     */
    @GET
    @Path("/{itsmcode}/engineers/q")
    public RestResponse<List<EngineerVO>> listEngineer(@PathParam("itsmcode") String itsmCode,
                                                        @QueryParam("filter") String condition,
                                                        @QueryParam("page") int page,
                                                        @QueryParam("limit") int limit,
                                                        @QueryParam("sorts}") String sorts);
}
